<?php
/**
 *MiniProgramLoginController
 * @author tan bing
 * @date 2021-08-11 9:35
 */


namespace Modules\User\Http\Controllers\Api;


use Modules\User\Services\Api\MiniProgramServices;
use Nwidart\Modules\Facades\Module;

class MiniProgramLoginController extends ApiBaseController
{

    /**
     * @var MiniProgramServices
     * @author tan bing
     */
    private $miniProgramServices;

    /**
     * MiniProgramLoginController constructor.
     *
     * @param MiniProgramServices $miniProgramServices
     * @author tan bing
     * @date 2021-08-11 12:44
     */
    public function __construct(MiniProgramServices $miniProgramServices)
    {
        $this->miniProgramServices = $miniProgramServices;
    }

    /**
     * 小程序登录
     *
     * @return mixed
     * @author tan bing
     * @date 2021-08-11 12:41
     */
    public function login()
    {
        try {
            $result = $this->miniProgramServices->miniProgramSessionData('login');
        } catch (\Exception $e) {
            return $this->failed($e->getMessage());
        }

        return $this->success($result);
    }

    /**
     * 绑定手机号
     * @return mixed
     * @author tan bing
     * @date 2021-10-29 15:26
     */
    public function binding()
    {
        try{
            $result = $this->miniProgramServices->miniProgramSessionData('binging');
        } catch (\Exception $e) {
            return $this->failed($e->getMessage());
        }

        return $this->success($result);
    }

    public function aaa($n)
    {
        return ($n * $n * $n);
    }
}